package com.zerdoor.service.impl;

import com.zerdoor.dao.IProductionListDao;
import com.zerdoor.service.IProductionListService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * Created by zhongjieyu on 2014/11/13.
 * 作品集列表 业务层实现类
 */
@Service
public class ProductionListServiceImpl implements IProductionListService {

    @Autowired
    private IProductionListDao productionListDao;


    @Override
    public Map<String, Object> findInitData() throws Exception {

        Map<String ,Object> dataMap = new HashMap<String, Object>();

        dataMap.put("artistGrade",productionListDao.findMinorCodeByMajorid(126));

        return dataMap;
    }

    @Override
    public List<Map<String, String>> selectAllProductionList(Map<String, String> param) throws Exception {

        //判断售价区间不为空
        if(param.get("price") != null && !"".equals(param.get("price")) ){

            String str[] = param.get("price").split("-");

            param.put("price_lower", str[0]);
            param.put("price_upper", str[1]);


        }

        return productionListDao.selectAllProductionList(param);
    }

    @Override
    public void updateClickRateByWorksId(int worksId) throws Exception {

        productionListDao.updateClickRateByWorksId(worksId);
    }
}
